<!--#include virtual="/dzps/p1.asp"-->
<script language="JScript" runat="Server">
    function ToObject(json) {
        var o;
        eval("o=" + json);
        return o;
    }

    function toArray(s) {
        var dic = Server.CreateObject("Scripting.Dictionary")
        eval("var a=" + json);
        for (var i = 0; i < a.length; i++) {
            var obj = Server.CreateObject("Scripting.Dictionary")
            for (x in a[i]) obj.Add(x, a[i][x])
            dic.Add(i, obj);
        }
        return dic
    }
</script>
<%
dim action,ret,sql,rs,json

json = request.form
action=Easp.Var("action")

dim myg_conn,myg_rs


select case action
	case "tl_post" tl_post
	case "prj_del_sel" prj_del_sel
	case "log1_add" 	log1_add	
	case "log1_add2" 	log1_add2
	case "equipmentType_l" 	equipmentType_l
	case "prn_l" 	prn_l
	case "prn_l2" 	prn_l2
	case "prn_upd" 	prn_upd
	case "prn_add" 	prn_add
	case "prn_del" 	prn_del
	case "equipmentType_add"		equipmentType_add
	case "equipmentType_del"		equipmentType_del
	case "equipmentType_upd"		equipmentType_upd
	case "log1_l"		log1_l
	case "log1_del"		log1_del
	case "log1_upd"		log1_upd
	case "status_l"		status_l
	case "status_add"		status_add
	case "status_upd"		status_upd
	case "status_del"		status_del
	case "typ_l" 	typ_l
	case "eqi_l" 	eqi_l
	case "typ_add" 		typ_add
	case "typ_upd"		typ_upd
	case "typ_del"		typ_del
	case "eqi_add" 		eqi_add
	case "eqi_upd"		eqi_upd
	case "eqi_del"		eqi_del		
	case "user_typ_l"		user_typ_l
	case "user_typ_add"		user_typ_add
	case "user_typ_upd"		user_typ_upd
	case "user_typ_del"		user_typ_del
	case "log1_tlp_add"		log1_tlp_add
	case "test"		test
	case "compute_log1"		compute_log1
	case "xd_add2"		xd_add2
	case "log1_sum" log1_sum
	case "log1_overtime_l" log1_overtime_l
	case "log1_overtime_send" log1_overtime_send
	case "log1_qmess" log1_qmess
	Case "baseinfo_l" baseinfo_l
	Case "baseinfo_add"	baseinfo_add
	case "baseinfo_del" baseinfo_del
	case "baseinfo_upd" baseinfo_upd
	Case "yjzt_l" yjzt_l
	Case "yjzt_add"	yjzt_add
	case "yjzt_del" yjzt_del
	case "yjzt_upd" yjzt_upd	
	Case "pat_file_add" pat_file_add
end select
function pat_file_add()
	dim sqla(10)
	vas "typ","1089"
	vas "id",val(hr_1("id"))


	vas "status","898"
	vas2 "questionDescription",replace(val("questionDescription"),"'","‘")
	vas "declareTele",session("username")

	vas "repairerId",val(hr_1("repairerId"))
	s1 "select name1 as status from baseinfo where id={status:int}"
	s1 "select truename from [user] where id={repairerId:int}"
	
	sqla(0)=cr2("[log1]","status,typ,repairerId,questionDescription,declareTele,pat_file")
	ret=execsw(sqla)
	rt ret
end function
Function yjzt_upd()
	dim sqla(10)
	vas "id",val(hr_1("id")) 
	vas "mode","医技状态"
	sqla(0)=xg2("[baseinfo]","name1,mode,name3,name2","id={id:int}")
	ret=execsw(sqla)
	rt ret
End Function
Function yjzt_del()
	dim ret
	ret = Easp.Db.Del("[baseinfo]","id={id:int}")
	rt ret
End Function
Function yjzt_add()
	dim sqla(10)
	vas "mode","医技状态"
	sqla(0)=cr2("[baseinfo]","name1,mode,name2,name3")
	ret=execsw(sqla)
	rt ret
End Function
function yjzt_l()
	dim sql,tn
	tn="yjzt"
	sql="select * from baseinfo where (1=1) and (2=2) and (mode='医技状态')"
	if val(tn & "_search")<>"" then
		vas "likeKey" ,"%{="&tn&"_search}%"
		sql=replace(sql,"1=1","name1 like {likeKey} or name2 like {likeKey}" )
	end if
	qry2json(sql)
end function
Function baseinfo_upd()
	dim sqla(10)
	vas "id",val(hr_1("id")) 
	vas "mode","医技类型"
	sqla(0)=xg2("[baseinfo]","name1,mode,name3,name2","id={id:int}")
	ret=execsw(sqla)
	rt ret
End Function
Function baseinfo_del()
	dim ret
	ret = Easp.Db.Del("[baseinfo]","id={id:int}")
	rt ret
End Function
Function baseinfo_add()
	dim sqla(10)
	vas "mode","医技类型"
	sqla(0)=cr2("[baseinfo]","name1,mode,name2,name3")
	ret=execsw(sqla)
	rt ret
End Function
function baseinfo_l()
	dim sql,tn
	tn="baseinfo"
	sql="select * from baseinfo where (1=1) and (2=2) and (mode='医技类型')"
	if val(tn & "_search")<>"" then
		vas "likeKey" ,"%{="&tn&"_search}%"
		sql=replace(sql,"1=1","name1 like {likeKey} or name2 like {likeKey}" )
	end if
	qry2json(sql)
end function
Function tl_post()
	dim sql
	' echo val("log1_id")
	sql="select a.id,a.add_time,title,user_id,b.username from tl_post a,[user] b where a.user_id=b.id and log1_id={log1_id:int} order by a.id desc"
	qry2json(sql)
end function
Function log1_overtime_l()
	dim sql,fields,tn
	tn="log1"
	sql="select * from (select count(log1.id) as cnt,[user].truename,[user].mobile from v_log1,[user]  where v_log1.repairerId=[user].id and (v_log1.[status]=899) and (1=1) and (2=2) and (3=3) and (5=5) and (6=6) group by [user].truename,[user].mobile ) "
	if val(tn & "_search")<>"" then
		vas "likeKey" ,"%{=log1_search}%"
		sql=replace(sql,"1=1","questionDescription like {likeKey} or truename like {likeKey}" )
	end if
	if val("typ")<>"" then
		sql=replace(sql,"2=2","typ = {typ}")
	end if
	if val("status")<>"" then
		sql=replace(sql,"3=3","status = {status}")
	end if
	if val("sd")<>"" and val("ed")<>"" then
		sql=replace(sql,"5=5","submitTime >= #"& val("sd")&" 00:00:00# "& " and " & "submitTime<=#"&val("ed") & " 23:59:59#")
	else
		vas "sd",Format_Time(now()-10,2)
		vas "ed",Format_Time(now()-3,2)
		sql=replace(sql,"5=5","submitTime >= #"& val("sd")&" 00:00:00# "& " and " & "submitTime<=#"&val("ed") & " 23:59:59#")
	end if
	if val("repairerId")="" then
		' vas "repairerId",session("user_id")
		' sql=replace(sql,"6=6","repairerId = {repairerId}")
	else
		sql=replace(sql,"6=6","repairerId = {repairerId}")
	end if
	qry2json(sql)
End Function
function log1_overtime_send()
	dim sql,arr,maxcol,maxrow,i,j,txt,ret
	sql="select * from (select count(log1.id) as cnt,[user].truename,[user].mobile from v_log1,[user]  where v_log1.repairerId=[user].id and (v_log1.[status]=899) and (6=6) group by [user].truename,[user].mobile ) "
	arr= sql2arr(sql)
	maxcol=ubound(arr,1)
	maxrow=ubound(arr,2)

	for i=0 to maxrow
		vas "phone",arr(2,i)
		vas "cnt",arr(0,i)
		txt="您有"& val("cnt") & "条超时工单。请及时处理！"
		vas "mess_text",txt
		send_mess val("phone"),val("txt")
	next	
	rt ret
end function
Function qry2json2(myg_conn1,sql)
	dim rs,rsjson,json,s
	dim a,b
	easp.db.pagesize = easp.var("limit")
	' set rs  = Easp.Db.GetRs(sql)
	set rs  = Easp.Db.GetRecordSet(myg_conn1, sql)
	
	Easp.Json.EncodeUnicode=false
	rsjson=Easp.Encode(rs)
	Easp.Db.Close(rs)
	set json=Easp.Decode(rsjson)
	json.put "total",easp.db.pagerecordcount

	s = json.toString()
	a =  instr(s,"[")
	b =  instr(s,"]")
	s = replace(s,"rows","data")
	s = replace(s,"total","count")
	
	echo replace(s,"{",  "{" & syh("code") & ":0,"  & syh("msg") & ":" & syh("") & ",",1,1)
	set json = nothing
End Function

function log1_qmess()

	sql="select * from mess where  mess_text " & hr_b(val("sx1_input")) &" order by id desc"

	sql="select * from mess where mysource=1 and mess_text " & hr_b(val("sx1_input")) &" order by id desc"

	qry2json2 myg_conn,sql

end function

function myg()
	dim myg_rs
	Set myg_rs = Easp.Db.Execute(myg_conn, "select TIMESTAMPDIFF(MINUTE,end_time,now()) as tdmi from gh_run_status ORDER BY id desc LIMIT 1")
	myg=myg_rs(0)
	myg_rs.close
	set myg_rs=Nothing
end function

Function xd_add2()
	save_html2 val("log1_id"),val("content")
	rt 1
End Function

Function save_html2(log1_id,content)
	dim conn3,rs1
	Set Conn3 = Easp.Db.GetConn
	sql = "select * from log1 where id="&log1_id
	Set rs = server.CreateObject("adodb.recordset")
	rs.open sql,conn3,1,3
	if rs.recordcount=0 then
		'rs.addnew
	else
	end if
	rs("fxpwd")=content
	'rs("log1_id")=val("log1_id")
	'rs("user_id")=session("user_id")
	rs.update
	rs.Close
	Set rs = Nothing
End Function
Function save_html(log1_id,content)
	dim conn3,rs1
	Set Conn3 = Easp.Db.GetConn
	sql = "select top 1 * from xd_p where log1_id="&log1_id
	Set rs = server.CreateObject("adodb.recordset")
	rs.open sql,conn3,1,3
	if rs.recordcount=0 then
		rs.addnew
	else
	end if
	rs("content")=content
	rs("log1_id")=val("log1_id")
	rs("user_id")=session("user_id")
	rs.update
	rs.Close
	Set rs = Nothing
End Function

sub compute_log1
	dim rc1,td,overtime
	rc1=rc("select id from [log1] where status=(select id from baseinfo where mode='工单状态' and name1='已处理' )")
	vas "done",rc1
	rc1=rc("select id from [log1] where status=(select id from baseinfo where mode='工单状态' and name1='处理中' )")
	vas "process",rc1	
	rc1=rc("select id from [log1] where status=(select id from baseinfo where mode='工单状态' and name1='未分配' )")
	vas "undistribute",rc1
	td = Format_Time(date(),2)
	rc1=rc("select id from [log1] where status=(select id from baseinfo where mode='工单状态' and name1='未分配') and (submitTime>=#" & td &" 00:00:00# and submitTime<=#" & td & " 23:59:59# )")
	vas "todayundistribute",rc1
	overtime=Format_Time(DateAdd("d",-2,now()),1) 
	rc1=rc("select id from [log1] where status=(select id from baseinfo where mode='工单状态' and name1='未分配') and (submitTime<=#" & overtime & "# )")
	vas "overtime",rc1
	vas "myg",myg()
	retJson "0","成功",dkh(json_help("done",val("done"))&","&json_help("myg",val("myg"))&","&json_help("todayundistribute",val("todayundistribute")) & "," & json_help("process",val("process")) & "," & json_help("undistribute",val("undistribute") ) & "," & json_help("overtime",val("overtime") )   )	
end sub

function json_help(key,value)
	dim txt
	txt= syh(key)&":"& value
	json_help=txt
end function
'card_post=id,title,cover_path,keywords,add_time,mod_time,pub_time,description,content,views,cat_id,user_id,allow_comment,is_display,is_delete,is_audit,comment_count,view_count,zan_count,cai_count,is_top,log1_id


Function test2()
	qry2json("select id,submitTime,[declare],declareTele,questionDescription from log1 where 1=1 order by id desc")
End Function
Function log1_tlp_add()
	dim sqla(10)
	vas hr_1("user_id"),session("user_id")
	sqla(0)=cr2("[tl_post]","title,log1_id,user_id")
	ret=execsw(sqla)
	rt ret
End Function
Function user_typ_add()
	dim sqla(10)
	vas hr_1("mode"),"用户类型"
	sqla(0)=cr2("[baseinfo]","name1,mode")
	ret=execsw(sqla)
	rt ret
End Function
Function user_typ_upd()
	dim sqla(10)
	vas "id",val(hr_1("id")) 
	sqla(0)=xg2("[baseinfo]","name1","id={id:int}")
	ret=execsw(sqla)
	rt ret
End Function
Function user_typ_del()
	dim ret
	ret = Easp.Db.Del("[baseinfo]","id={id:int}")
	rt ret
End Function
Function user_typ_l()
	sql="select id,name1 from baseinfo  where (1=1) and (mode='用户类型')"
	if val("user_typ_search")<>"" then
		vas "likeKey" ,"%{=user_typ_search}%"
		sql=replace(sql,"1=1","name1 like {likeKey}")
	end if
	qry2json(sql)
end function
Function eqi_add()
	dim sqla(10)
	vas hr_1("mode"),"设备类型"
	sqla(0)=cr2("[baseinfo]","name1,mode")
	ret=execsw(sqla)
	rt ret
End Function
Function eqi_upd()
	dim sqla(10)
	vas "id",val(hr_1("id")) 
	sqla(0)=xg2("[baseinfo]","name1","id={id:int}")
	ret=execsw(sqla)
	rt ret
End Function
Function eqi_del()
	dim ret
	ret = Easp.Db.Del("[baseinfo]","id={id:int}")
	rt ret
End Function
Function eqi_l()
	sql="select id,name1 from baseinfo  where (1=1) and (mode='设备类型')"
	if val("eqi_search")<>"" then
		vas "likeKey" ,"%{=eqi_search}%"
		sql=replace(sql,"1=1","name1 like {likeKey}")
	end if
	qry2json(sql)
end function
Function typ_add()
	dim sqla(10)
	vas hr_1("mode"),"工单类型"
	sqla(0)=cr2("[baseinfo]","name1,mode")
	ret=execsw(sqla)
	rt ret
End Function
Function typ_upd()
	dim sqla(10)
	vas "id",val(hr_1("id")) 
	sqla(0)=xg2("[baseinfo]","name1","id={id:int}")
	ret=execsw(sqla)
	rt ret
End Function
Function typ_del()
	dim ret
	ret = Easp.Db.Del("[baseinfo]","id={id:int}")
	rt ret
End Function
Function typ_l()
	sql="select id,name1 from baseinfo  where (1=1) and (mode='工单类型')"
	if val("typ_search")<>"" then
		vas "likeKey" ,"%{=typ_search}%"
		sql=replace(sql,"1=1","name1 like {likeKey}")
	end if
	qry2json(sql)
end function
Function status_add()
	dim sqla(10)
	vas hr_1("mode"),"工单状态"
	sqla(0)=cr2("[baseinfo]","name1,mode")
	ret=execsw(sqla)
	rt ret
End Function
Function status_upd()
	dim sqla(10)
	vas "id",val(hr_1("id")) 
	sqla(0)=xg2("[baseinfo]","name1","id={id:int}")
	ret=execsw(sqla)
	rt ret
End Function
Function status_del()
	dim ret
	ret = Easp.Db.Del("[baseinfo]","id={id:int}")
	rt ret
End Function
Function status_l()
	sql="select id,name1 from baseinfo  where (1=1) and (mode='工单状态')"
	if val("status_search")<>"" then
		vas "likeKey" ,"%{=status_search}%"
		sql=replace(sql,"1=1","name1 like {likeKey}")
	end if
	qry2json(sql)
end function

Function prn_del()
	dim ret
	ret = Easp.Db.Del("[equipment]","id={id:int}")
	rt ret
End Function
Function prn_add()
	dim sqla(10),rc1
	vas "machineNo",val("machineNo")
	rc1= rc("select id from [equipment] where machineNo={machineNo}")
	'val("machineNo")<>"" 用于没有机器号的情况
	if rc1=1 and val("machineNo")<>"" then 
		s1 "select id as id1 from [equipment] where machineNo={machineNo}"
		rt2 0,"machineNo 机器号" & val("machineNo") & " 重复id=" & val("id1")
	else
		sqla(0)=cr2("[equipment]","department,[local],machineNo,equipmentTypeId,ipadr")
		ret=execsw(sqla)
		rt ret		
	end if	
End Function
Function save_html(log1_id,content)

End Function
Function log1_del()
	dim sqla(10),rc1
	ret = Easp.Db.Del("[log1]","id={id:int}")
	ret=execsw(sqla)
	rt ret
End Function
Function log1_add2()
	dim sqla(10)
	sqla(0)=cr2("[log1]","[declare],declareTele,questionDescription,typ,status,ans,title1,fxpwd")'fxpwd'
	ret=execsw(sqla)
	rt ret
End Function
Function log1_add()
	if request("code")<>request.Cookies("AsaiCode") then
		rt2 0,"验证码不正确！"
		response.end
	end if
	dim sqla(10)
	vas2 "questionDescription",replace(val("questionDescription"),"'","‘")
	sqla(0)=cr2("[log1]","equipmentId,[declare],declareTele,questionDescription,typ,status")
	ret=execsw(sqla)
	rt ret
	
	vas "mess_text","您的工单提交成功，信息科将及时处理。"
	vas "phone",val("declareTele")
	send_mess val("phone"),val("mess_text")
	' response.end
	vas "mess_text","收到工单:"& val("questionDescription") & " 来自：" & val("declare") & val("declareTele")  &  "，请及时处理。"
	vas "phone",val("mobile")
	send_mess val("phone"),val("mess_text")
End Function


Function send_mess(phone,mess_text)
	dim sql,ret
	vas "date",Format_Time(now(),2)
	vas "mysource","1"

	vas "phone",phone
	vas "mess_text",mess_text
	sql=cr("mess","phone,mess_text,date,mysource")
	ret= Easp.Db.Execute(myg_conn, sql)
	send_mess=ret
end function
Function log1_upd()
	dim sqla(10)
	vas "id",val(hr_1("id"))
	vas2 "questionDescription",replace(val("questionDescription"),"'","‘")
	vas2 "status",val("status")
	sqla(0)=xg2("[log1]","status,typ,questionDescription,ans,title1,fxpwd","id={id:int}" )'repairerId fxpwd'
	vas "status",val(hr_1("status"))
	vas "repairerId",val(hr_1("repairerId"))
	s1 "select name1 as status from baseinfo where id={status:int}"
	s1 "select truename from [user] where id={repairerId:int}"
	
	ret=execsw(sqla)
	rt ret


End Function
Function prn_upd()
	dim sqla(10),rc1
	vas "id",val(hr_1("id"))
	vas "machineNo",val(hr_1("machineNo"))
	rc1= rc("select id from [equipment] where machineNo={machineNo}")
	if rc1>1 then
		rt 0,"machineNo 机器号" & val(hr_1("machineNo")) & " 重复"
	else
		sqla(0)=xg2("[equipment]","department,[local],machineNo,equipmentTypeId,ipadr","id={id:int}" )
		ret=execsw(sqla)
		rt ret
	end if
End Function
Function equipmentType_del()
	dim ret
	ret = Easp.Db.Del("[equipmentType]","id={id:int}")
	rt ret
End Function
Function equipmentType_upd()
	dim sqla(10),rc1
	vas "id",val(hr_1("id"))
	rc1= rc("select id from [equipmentType] where equipmentName={equipmentName}")
	if rc1>1 then
		rt 0,"equipmentName 打印机型号" & val(hr_1("equipmentName")) & " 重复"
	else
		sqla(0)=xg2("[equipmentType]","equipmentName,typ","id={id:int}")
		ret=execsw(sqla)
		rt ret		
	end if	
End Function
Function equipmentType_add()
	dim sqla(10),rc1
	rc1= rc("select id from [equipmentType] where equipmentName={equipmentName}")
	if rc1=1 then
		rt 0,"equipmentName 打印机型号" & val(hr_1("equipmentName")) & " 重复"
	else
		sqla(0)=cr2("[equipmentType]","equipmentName,typ")
		ret=execsw(sqla)
		rt ret		
	end if	
End Function
Function equipmentType_l()
	dim sql,fields
	sql="select * from equipmentType  where (1=1)"
	if val("equipmentType_search")<>"" then
		vas "likeKey" ,"%{=equipmentType_search}%"
		sql=replace(sql,"1=1","equipmentName like {likeKey}")
	end if
	qry2json(sql)
End Function
Function test()
	dim sql,arr
	sql="select questionDescription from log1 where questionDescription like '*''*'"
	' arr= sql2arr(sql)
	' sql="update log1 set questionDescription=replace(questionDescription,'''','’') where questionDescription like '*''*'"
	' execsw sql

end function

Function log1_sum()
	dim sql
	easp.db.del "temp_sum1","1=1"
	sql= "select distinct truename from v_log1"
	gen_temp_sum0 sql
	
	sql="select truename,count(id) as cnt1 from v_log1 where status=899 group by truename"
	gen_temp_sum sql,"cnt1"

	sql="select truename,count(id) as cnt2 from v_log1 where status=900 group by truename"
	gen_temp_sum sql,"cnt2"

	sql="select truename,count(id) as cnt2 from v_log1 where status=1032 group by truename"
	gen_temp_sum sql,"cnt3"	
	
	sql="select * from temp_sum1 order by cnt1 desc"
	qry2json(sql)
End Function
Function gen_temp_sum0(sql)
	dim arr,i,maxcol,maxrow,j
	arr=sql2arr(sql)
	maxcol=ubound(arr,1)
	maxrow=ubound(arr,2)
	for i=0 to maxrow
		for j=0 to maxcol
			vas "truename",arr(j,i)
			sql=cr("temp_sum1","truename")
			execsw sql
		next
	next
End function

Function gen_temp_sum(sql,fieldn)
	dim arr,maxcol,maxrow,i,j
	arr=sql2arr(sql)
	if ubound(arr)=0 then
	else
		maxcol=ubound(arr,1)
		maxrow=ubound(arr,2)
		for i=0 to maxrow
			vas "truename",arr(0,i)
			vas fieldn,arr(1,i)
			sql=xg("temp_sum1",fieldn,"truename={truename}")
			execsw sql
		next
	end if
End function

Function log1_l()
	dim sql,fields,tn
	tn="log1"
	sql="select id,equipmentId,repairerId,questionDescription,[declare],declareTele,submitTime,[status],name1,equipmentname,typ,typ_name,repairerId,truename from v_log1  where (1=1) and (2=2) and (3=3) and (5=5) and (6=6) order by id desc"
	if val(tn & "_search")<>"" then
		vas "likeKey" ,"%{=log1_search}%"
		sql=replace(sql,"1=1","questionDescription like {likeKey} or truename like {likeKey}" )
	end if
	if val("typ")<>"" then
		sql=replace(sql,"2=2","typ = {typ}")
	end if
	if val("status")<>"" then
		sql=replace(sql,"3=3","status = {status}")
	end if
	if val("sd")<>"" and val("ed")<>"" then
		sql=replace(sql,"5=5","submitTime >= #"& val("sd")&" 00:00:00# "& " and " & "submitTime<=#"&val("ed") & " 23:59:59#")
	else
		vas "sd",Format_Time(now()-5,2)
		vas "ed",Format_Time(now(),2)
		sql=replace(sql,"5=5","submitTime >= #"& val("sd")&" 00:00:00# "& " and " & "submitTime<=#"&val("ed") & " 23:59:59#")
	end if
	if val("repairerId")="" then
		' vas "repairerId",session("user_id")
		' sql=replace(sql,"6=6","repairerId = {repairerId}")
	else
		sql=replace(sql,"6=6","repairerId = {repairerId}")
	end if
	qry2json(sql)
End Function

Function prn_l2()
	dim sql,fields
	sql="select id,name1 from baseinfo where mode='用户类型'  and (1=1) and (2=2)"
	if val("keyword")<>"" then
		vas "likeKey" ,"%{=keyword}%"
		sql=replace(sql,"1=1","name1 like {likeKey}")
	end if

	qry2json(sql)
End Function

Function prn_l()
	dim sql,fields
	sql="select id,department,[local],machineNo,equipmentTypeId,equipmentName,ipadr from v_prn  where (1=1) and (2=2)"
	if val("prn_search")<>"" then
		vas "likeKey" ,"%{=prn_search}%"
		sql=replace(sql,"1=1","department like {likeKey}")
	end if
	if val("typ")<>"" then
		sql=replace(sql,"2=2","typ = {typ}")
	else
        s1 "select id as typ from baseinfo where mode='设备类型'"
		sql=replace(sql,"2=2","typ = {typ}")
	end if

	qry2json(sql)
End Function
Function prj_del_sel()
	dim result,ob,i,ids,ret
	Set ob = toArray(json)
	For i=0 To ob.Count-1
		easp.var("id")=ob(i)("id")
		ret = Easp.Db.del("prj","id={id:int}")
	next
	Set ob = Nothing
End Function

Function da(txt)
	txt = chr(39)&txt&chr(39)
	da=txt
End Function

Function lbfh(txt)
	txt=da("%"&txt&"%")
	lbfh=" like " & txt
End Function

Function bfh(txt)
	txt=da("%"&txt&"%")
	bfh=txt
End Function

Function dkh(txt)
	txt="{"&txt&"}"
	dkh=txt
End Function

Function xkh(txt)
	txt="("&txt&")"
	xkh=txt
End Function

Function daj(txt)
	txt = "#" & txt& "#"
	daj=txt
End Function

Function hr_1(txt)
	hr_1="field[" & txt & "]"
End Function

Function getCheckData()
	dim result,ob,i,ids
	Set ob = toArray(json)
	For i=0 To ob.Count-1
	  ids=ids&ob(i)("ID") & "," 
	next
	easp.var("ids")=left(ids,len(ids)-1)
	Set ob = Nothing	
	result=easp.db.del("jf","id in ({ids})")
End Function
Function batchQrjf()
	dim result,ob,i,ids,ret
	Set ob = toArray(json)
	For i=0 To ob.Count-1
		' ids=ids&ob(i)("ID") & "," 
		easp.var("id")=ob(i)("ID")
		set rs=easp.db.sel("select qrjf from [jf] where id={id}")
		if rs("qrjf")=0 then
			ret=Easp.Db.Upd ("[jf]","qrjf=1","id={id}")    	
		end if
	next
	Set ob = Nothing
End Function

Function clearSession()
	session("username")=""
	session("password")=""
End Function
%>